#include "IHelper.h"
#include "..\Engine\IEngine.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>

/*Interface Helper class not to be used  no defination for interface*/
/*It should act as base abstarct class*/

IHelper::IHelper(IEngine *engine): mEngine(engine)
{
}

IHelper::~IHelper(void)
{
}

void IHelper::DebugLog(char *fmt, ...)
{
       	/* var length arg list function similar to printf() */
	char *s;
	float f;
	int i,j,lenfmt;
	va_list ap; /* argument pointer */
	va_start(ap,fmt); /* make ap point to first unnamed argument */
	lenfmt=strlen(fmt);
	for(j=0;j<lenfmt;j++){
		if(fmt[j]!='%'){
			putchar(fmt[j]);
		} else {
			j++;
			if(fmt[j]=='d'){
				i=va_arg(ap,int);
				printf("%d",i);
			} else if(fmt[j]=='f'){
				f=(float)va_arg(ap,double);
				printf("%f",f);
			} else if(fmt[j]=='s'){
				s=va_arg(ap,char*);
				while(*s)
					putchar(*s++);
			} else 
				putchar(fmt[j]);
		}
			
	}
}
